import request from '@/utils/request'
import type { ApiResult, BaseIds, PageSchema } from '@/api/api'
import type { Dict, DictAddDTO, DictModDTO, DictQueryDTO } from '@/api/system/dict/type'

const BASE_URL = '/admin/api/v1/system/dict'

const API = {
  BASE_URL,
  PAGE_URL : BASE_URL + '/page',
  LIST_URL : BASE_URL + '/list',
  REMOVE_URL : BASE_URL + '/rm',
}
// 添加字段信息
export const dictAdd = (data: DictAddDTO) => {
  return request.post<any, ApiResult<unknown>>(API.BASE_URL, data)
}
// 修改字段信息
export const dictMod = (data: DictModDTO) => {
  return request.put<any, ApiResult<unknown>>(API.BASE_URL, data)
}
// 删除字段信息
export const dictDel = (data: BaseIds) => {
  return request.post<any, ApiResult<unknown>>(API.REMOVE_URL, data)
}
// 查询字段信息
export const dictList = (data: DictQueryDTO) => {
  return request.post<any, ApiResult<Dict[]>>(API.LIST_URL, data)
}
// 查询分页数据
export const dictQuery = (data: DictQueryDTO) => {
  return request.post<any, ApiResult<PageSchema<Dict>>>(API.PAGE_URL, data)
}